package cuiyt.algorithm.dfs;

import algorithm.TreeNode;

/**
 * @author cyt
 * @create 2020-08-24 18:08
 */
public class T897_2 {
    TreeNode cur;

    public TreeNode increasingBST(TreeNode root) {
        TreeNode ans = new TreeNode(0);
        cur = ans;
        inorder(root);
        return ans.right;
    }

    public void inorder(TreeNode node) {
        if (node == null) {
            return;
        }
        inorder(node.left);
        node.left = null;
        cur.right = node;
        cur = node;
        inorder(node.right);
    }
}
